<!doctype html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport"
        content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>js条件判断之switch</title>
</head>
<body>
  <script>
    function getMessage(type) {
      switch (type.toLowerCase()) {
        case 'info':
        case 'notice':
          console.log('提示或通知消息')
          break
        case 'warning':
          console.log('警告消息')
          break
        case 'error':
        default:
          console.log('错误消息')
          break
      }
    }
    getMessage('info')
    getMessage('notice')
    getMessage('warning')
    getMessage('error')
  </script>
</body>
</html>